import type { RowType } from '#/views/system/sysUser/sysUser.data';

import { requestClient } from '#/api/request';

export namespace SysUserTableApi {
  export type RowTypeFetchParams = RowType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
  export interface PageListFetchParams {
    [key: string]: any;
    pageNo: number;
    pageSize: number;
  }
}

/**
 * 分页列表查询
 */
export async function sysUserQueryPageListApi(
  params: SysUserTableApi.PageListFetchParams,
) {
  return requestClient.get('/sys/user/queryPageList', { params });
}

/**
 * 列表查询
 */
export async function sysUserQueryListApi(
  params: SysUserTableApi.ListFetchParams,
) {
  return requestClient.get('/sys/user/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function sysUserQueryByIdApi(
  params: SysUserTableApi.IdFetchParams,
) {
  return requestClient.get('/sys/user/queryById', { params });
}

/**
 * 新增
 */
export async function sysUserAddApi(
  params: SysUserTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/sys/user/add', params);
}

/**
 * 编辑
 */
export async function sysUserEditApi(
  params: SysUserTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/sys/user/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function sysUserDelApi(id) {
  return requestClient.delete<boolean>(`/sys/user/delete/${id}`);
}

/**
 * 批量删除删除
 * @param ids 主键
 */
export async function sysUserDeleteBatchApi(ids) {
  return requestClient.delete<boolean>(`/sys/user/deleteBatchByIds/${ids}`);
}

/**
 * 重置密码
 */
export async function sysUserResetPassWordApi() {
  return requestClient.post('/sys/user/resetPassWord');
}
